In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
Byteasar is a manager in Byteland Worldbeat Publishers (BWP). There are composers and lyricists employed there. The artists work in pairs consisting of one composer and one lyricist.
Byteasar knows the skills of BWP employees. Thus he can assess how effective a composer-lyricist pair is going to be. The efficiency of each potential pair is measured as the number of songs written per week.
Byteasar wants to arrange the employees in disjoint pairs such that the number of songs produced is as high as possible. Unpaired artists will not work.
After the analysis of the whole data Byteasar suspects that the total number of songs produced in BWP during a week is independent of the paring. Byteasar is surprised, therefore he asks you to write a program to verify this observation.
The first line of input contains one integer (), i.e., the number of test cases that follow.
Each test case starts with a line with three integers , and (, ) that are the number of composers, the number of lyricists and the number of lines describing the efficiency of pairs. Composers are numbered from to , while lyricists are numbered from to .
Each of the next subsequent lines contains four integers , , and (, , ) with the meaning that a pair of composer and any lyricist from the range to (inclusive) will produce songs per week.
Each composer-lyricist pair will be described at most once. If a pair is not mentioned in the input, its members will be assumed to be skilled in incompatible music genres, thus the efficiency of their work will be songs a week. Nevertheless such a pair can be formed in BWP.
Your program should output lines with answers for subsequent test cases. For each test case the answer is TAK (i.e., yes in Polish) if for each arrangement of pairs, the total efficiency is the same. Otherwise, the answer is NIE (no in Polish).
For the input data:
2 2 3 3 1 1 3 3 2 1 1 3 2 2 3 3 3 3 7 1 1 1 5 1 2 2 6 2 1 1 5 2 2 2 6 3 1 1 8 3 2 2 9 3 3 3 10
the correct result is:
TAK NIE
Task author: Krzysztof Diks.